package com.zys.el.user.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zys.el.core.service.impl.CrudServiceImpl;
import com.zys.el.user.dao.FieldDao;
import com.zys.el.user.po.Field;
import com.zys.el.user.service.IFieldService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FieldServiceImpl extends CrudServiceImpl<Field> implements IFieldService {


    @Override
    public String[] selectUserFieldById(Long[] FieldId) {
        String[] UserField = new String[FieldId.length];
        for (Integer i = 0; i < FieldId.length; i++) {
            Field byId = ((FieldDao) getBaseMapper()).selectById(FieldId[i]);
//            System.out.println(byId);
            UserField[i] = byId.getFieldName();
        }
        return UserField;
    }

    @Override
    public Field QueryFieldByName(String name) {
        QueryWrapper<Field> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("field_name_", name);
        return getBaseMapper().selectOne(objectQueryWrapper);
    }

    @Override
    public List<Field> QueryFieldByLikeName(String name) {
        QueryWrapper<Field> qw = new QueryWrapper<>();
        qw.like("field_name_", name);
        return getBaseMapper().selectList(qw);
    }


}
